package cn.stylefeng.guns.modular.erlove.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.erlove.service.ErLoveService;
import cn.stylefeng.guns.modular.erlove.model.param.ErLoveParam;

import javax.annotation.Resource;

/**
 * 点赞 控制器
 *
 * @author: w
 * @date: 2021/06/11 15:02
 */
@RestController
public class ErLoveController {

    @Resource
    private ErLoveService erLoveService;

    /**
     * 分页查询点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @GetMapping("/erLove/page")
    @BusinessLog(title = "点赞_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(ErLoveParam erLoveParam) {
        return new SuccessResponseData(erLoveService.page(erLoveParam));
    }

    /**
     * 获取全部点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @GetMapping("/erLove/list")
    @BusinessLog(title = "点赞_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(ErLoveParam erLoveParam) {
        return new SuccessResponseData(erLoveService.list(erLoveParam));
    }

    /**
     * 查看详情点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @GetMapping("/erLove/detail")
    @BusinessLog(title = "点赞_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(ErLoveParam.detail.class) ErLoveParam erLoveParam) {
        return new SuccessResponseData(erLoveService.detail(erLoveParam));
    }

    /**
     * 添加点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @PostMapping("/erLove/love")
    @BusinessLog(title = "点赞_增加_取消")
    public ResponseData love(@RequestBody ErLoveParam erLoveParam) {
        return new SuccessResponseData(erLoveService.love(erLoveParam));
    }
    /**
     * 点赞状态
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @PostMapping("/erLove/showLoveState")
    @BusinessLog(title = "点赞状态")
    public ResponseData showLoveState(@RequestBody ErLoveParam erLoveParam) {
        return new SuccessResponseData(erLoveService.showLoveState(erLoveParam));
    }
    /**
     * 删除点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @PostMapping("/erLove/delete")
    @BusinessLog(title = "点赞_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(ErLoveParam.delete.class) ErLoveParam erLoveParam) {
        erLoveService.delete(erLoveParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑点赞
     *
     * @author w
     * @date 2021/06/11 15:02
     */
    @PostMapping("/erLove/edit")
    @BusinessLog(title = "点赞_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(ErLoveParam.edit.class) ErLoveParam erLoveParam) {
        erLoveService.edit(erLoveParam);
        return new SuccessResponseData();
    }



}
